import re
import requests
from pyquery import PyQuery as pq
from sql_helper import MySqlHelper
import json
import time
USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36'
headers = {
    "User-Agent": USER_AGENT
}


def read_jd_list(url, item_dict_all=None):
    if item_dict_all is None:
        item_dict_all = list()

    response = requests.get(url, headers=headers)
    if response.status_code == 200:
        print(response.text)


    else:
        print("你抓的出问题了！")

    return item_dict_all



if __name__ == "__main__":

        url = "https://www.lagou.com/jobs/positionAjax.json?px=default&city=%E9%83%91%E5%B7%9E&needAddtionalResult=false"
        item_dict_all = read_jd_list(url)
        mysql = MySqlHelper()
        # 岗位, 公司名称, 地址, 城市, 工资, 任职条件, 经验, 学历, 薪资待遇
        # sql = "INSERT INTO boos(`post`, `company`, `site`, `city`, `salary`, `condition`, `experience`, `education`, `welfare`) VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        # print(item_dict_all)
        # mysql.exec_many(sql, item_dict_all)
